DevForce Help Reference
WithGenerator(IEnumerable<Type>) Method
Example 


Creates a new CompositionContext from the current context with filtering for the types specified.
Syntax
'Declaration
 
Public Overloads Function WithGenerator( _
   ByVal types As IEnumerable(Of Type) _
) As CompositionContext
'Usage
 
Dim instance As CompositionContext
Dim types As IEnumerable(Of Type)
Dim value As CompositionContext
 
value = instance.WithGenerator(types)
public CompositionContext WithGenerator( 
   IEnumerable<Type> types
)

Parameters

types
Exceptions
ExceptionDescription
System.ArgumentExceptionThrown if any type does not have a composable base type or interface
Example
public class CompositionContextResolver : BaseCompositionContextResolver {
  // Creates a new context from the Default context, indicating that the
  // specified types should be used whenever an export
  // matching its interface/base class is requested.
  CompositionContext Mock = CompositionContext.Default
    .WithGenerator(new[] {
     typeof(MockEntityServerQueryInterceptor),
     typeof(MockEntityServerSaveInterceptor)
    })
    .WithName("Mock");
}

[PartNotDiscoverable]
public class MockEntityServerQueryInterceptor : EntityServerQueryInterceptor {

  protected override bool ExecuteQuery() {
    throw new InvalidOperationException();
  }
}
[PartNotDiscoverable]
public class MockEntityServerSaveInterceptor : EntityServerSaveInterceptor {

  protected override bool ExecuteSave() {
    throw new InvalidOperationException();
  }
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

CompositionContext Class
CompositionContext Members
Overload List

Send Feedback